import axios from "axios";
let axiosInstance = axios.create({
  // baseURL: "http://localhost:9000",
  timeout: 4000,
});
axiosInstance.interceptors.request.use(
  (config) => {
    config.headers.Authorization =
      "Bearer " +
      "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNDc5MjA1NjMiLCJ0b2tlbl9jcmVhdGVUaW1lIjoiMjAyMy0xMi0wNCAxODoyMDozMSIsInRva2VuX2V4cGlyYXRpb25UaW1lIjoiMjAyMy0xMi0xMSAxODoyMDozMSIsImlhdCI6MTcwMTY4NTIzMSwiZXhwIjoxNzAyMjkwMDMxfQ.yfQhte6Rs5IBG1fae4qoAZ6XtfPMl3bBh96NuWtpfGQ";
    console.log(config, "拦截");
    return config;
  },
  (err) => {
    //接口处理错误
    return Promise.reject(err);
  }
);
axiosInstance.interceptors.response.use(
  (response) => {
    if (response.status == 500) {
      alert("服务器出现错误");
    }
    //其他错误处理...
    return response.data; //这里必须返回 response，否则报错
  },
  (err) => {
    //接口处理错误
    return Promise.reject(err);
  }
);
export default axiosInstance;
